From c55a07df6b498adb3c570d22f0024d16fc052b41 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 16 Feb 2026 22:11:28 +0100 Subject: [PATCH] search: Do not check for class cancellable state after awaiting In an async function, after awaiting, the cancelled state for the class-tracked cancellable may not respect the actual state of the cancellable that has been used to perform the call. Thus, let's use a local variable instead Part-of: --- js/ui/search.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/js/ui/search.js b/js/ui/search.js index 7f72a87d2..76e49bc1e 100644 --- a/js/ui/search.js +++ b/js/ui/search.js @@ -226,11 +226,12 @@ const SearchResultsBase = GObject.registerClass({ return; this._cancellable.cancel(); - this._cancellable = new Gio.Cancellable(); + const cancellable = new Gio.Cancellable(); + this._cancellable = cancellable; - const metas = await this.provider.getResultMetas(metasNeeded, this._cancellable); + const metas = await this.provider.getResultMetas(metasNeeded, cancellable); - if (this._cancellable.is_cancelled()) { + if (cancellable.is_cancelled()) { if (metas.length > 0) throw new Error(`Search provider ${this.provider.id} returned results after the request was canceled`); } -- 2.39.5